# graph.py

r'''This is obsolete.  Use the :class:`.cutting_pass.debuggers.graph` instead.
'''

from __future__ import division

from PIL import Image, ImageDraw

from ot_simulator import graph as grapher
from ot_simulator.component import component

Max_dimension = 300

class graph(component.component):
    '''This graphs any two values.

    Call :py:meth:`show` at the end of the run.  This also resets the graph
    for the next run.

    ===============  ==============================
     Input setting   
    ===============  ==============================
    x, y             values to plot, no defaults
    ===============  ==============================

    ===============  ==========================
    Output setting
    ===============  ==========================
    <none>
    ===============  ==========================
    '''
    input_parameters = ('x', 'y')

    def __init__(self, **kws):
        super(graph, self).__init__(**kws)
        self.graph = grapher.graph()
        self.points = []

    def get_transform(self, params, transform_in):
        self.points.append((self.get_param(params, 'x'),
                            self.get_param(params, 'y')))
        return transform_in

    def show(self):
        self.graph.plot(self.points)
        self.graph.show()

def test():
    import doctest
    import sys
    sys.exit(doctest.testmod()[0])

if __name__ == "__main__":
    test()

